<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script type="text/javascript">
        fetch('/books', {
            method: 'post',
            body: 'uname=list&pwd=123', //用于传递实际的数据
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded' //固定的
            }
        }).then(data => {
            return data.text();
        }).then(ret => {
            console.log(ret);
        })

        fetch('/books', {
            method: 'post',
            body: JSON.stringify({
                uname: 'list',
                age: 12
            }), //用于传递实际的数据
            headers: {
                'Content-Type': 'application/x-www-form-urlencoded' //固定的
            }
        }).then(data => {
            return data.text();
        }).then(ret => {
            console.log(ret);
        })
    </script>
</body>

</html>